From Gerhard Olsson:
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 12 Jul 2013 01:21:00 +0000 (01:21 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 12 Jul 2013 01:21:00 +0000 (01:21 +0000)
Three parts. The second/third part is normally inactive in the code.

gtrnctr.c
Average Cadence in laps was handled as floats with one decimal but the xml format specifies char.
Some programs therefore failed to parse the generated xml
CadenceValue_t in http://www8.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd

jeeps
Cadence is invalid if it is 255 in Garmin USB. This is handled for track points but not for lap data.

garmin.c
(inactive) function read_lap_as_track() was not updated to the new string handling

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4419 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/garmin.cc
gpsbabel/gpx.cc
gpsbabel/gtrnctr.cc
gpsbabel/jeeps/gpsapp.cc

index 60eadbf6584f04489e63b5594468cf60c6c1c7a0..fda06a80f6ad77b3a38bb8e62ebb948b6abf3625 100644 (file)
@@ -592,6 +592,7 @@ lap_read_as_track(void)
   int trk_num = 0;
   int index;
   int i;
+  char tbuf[128];
 
   ntracks = GPS_Command_Get_Lap(portname, &array, waypt_read_cb);
   if (ntracks <= 0) {
@@ -617,8 +618,8 @@ lap_read_as_track(void)
       trk_head = route_head_alloc();
       /*For D906, we would like to use the track_index in the last packet instead...*/
       trk_head->rte_num = ++trk_num;
-      trk_head->rte_name = xmalloc(32);
-      strftime(trk_head->rte_name, 32, "%Y-%m-%dT%H:%M:%SZ", stmp);
+      strftime(tbuf, 32, "%Y-%m-%dT%H:%M:%SZ", stmp);
+      trk_head->rte_name = xstrdup(tbuf);
       track_add_head(trk_head);
 
       wpt = waypt_new();
@@ -631,13 +632,12 @@ lap_read_as_track(void)
       wpt->creation_time = array[i]->start_time;
       wpt->microseconds = 0;
 
-      wpt->shortname = xmalloc(8);
-      sprintf(wpt->shortname, "#%d-0", index);
-      wpt->description = xmalloc(128);
-      sprintf(wpt->description, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d",
+      sprintf(tbuf, "#%d-0", index);
+         wpt->shortname = xstrdup(tbuf);
+      sprintf(tbuf, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d",
               array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate,
               array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method);
-
+         wpt->description = xstrdup(tbuf);
       track_add_wpt(trk_head, wpt);
     }
     /*Allow even if no correct location, no skip if invalid */
@@ -655,13 +655,13 @@ lap_read_as_track(void)
     wpt->creation_time = array[i]->start_time + array[i]->total_time/100;
     wpt->microseconds = 10000*(array[i]->total_time % 100);
     /*Add fields with no mapping in the description */
-    wpt->shortname = xmalloc(8);
-    sprintf(wpt->shortname, "#%d", index);
-    wpt->description = xmalloc(128);
-    sprintf(wpt->description, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d (%f,%f)",
+    sprintf(tbuf, "#%d", index);
+    wpt->shortname = xstrdup(tbuf);
+    sprintf(tbuf, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d (%f,%f)",
             array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate,
             array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method,
             array[i]->begin_lon, array[i]->begin_lat);
+       wpt->description = xstrdup(tbuf);
 
     track_add_wpt(trk_head, wpt);
   }
index 245839b4b03b5e9ddc15abe2ce42fe91010dbaba..dcc878e19f097b70892e1a4583a244f8bdcd419d 100644 (file)
@@ -994,11 +994,13 @@ gpx_end(void* data, const XML_Char* xml_el)
     }
     break;
   case tt_cache_desc_long:
-    rtrim(cdatastrp);
-    if (cdatastrp[0]) {
+    {
       geocache_data* gc_data = waypt_alloc_gc_data(wpt_tmp);
       gc_data->desc_long.is_html = cache_descr_is_html;
-      gc_data->desc_long.utfstring = cdatastrp;
+// FIXME: Forcing a premature conversion here saves 4% on GPX read times
+// on large PQs.  Once cdatastrp becomes  real QString this is just (minimal)
+// overhead.
+      gc_data->desc_long.utfstring = QString(cdatastrp).trimmed();
     }
     break;
   case tt_cache_desc_short:
index ea1fce0e8585aeae2b4b935b828112ca0bac6940..0805660a652f05a617d1d1bd0548a926ab89171b 100644 (file)
@@ -327,7 +327,7 @@ gtc_waypt_pr(const waypoint* wpt)
     if (wpt->power) {
       gtc_write_xml(0, "<Watts>%.0f</Watts>\n", wpt->power);
     }
-    gtc_write_xml(-1, "</TPX>\n", wpt->cadence);
+    gtc_write_xml(-1, "</TPX>\n");
     gtc_write_xml(-1, "</Extensions>\n");
   }
 
@@ -359,7 +359,7 @@ gtc_fake_hdr(void)
     gtc_write_xml(-1,"</MaximumHeartRateBpm>\n");
   }
   if (tdata->avg_cad) {
-    gtc_write_xml(0, "<Cadence>%.1f</Cadence>\n", tdata->avg_cad);
+    gtc_write_xml(0, "<Cadence>%d</Cadence>\n", tdata->avg_cad);
   }
   gtc_write_xml(0, "<Intensity>Active</Intensity>\n");
 
index b21761b7be0751eae64a6f484316827fd41d896e..4c57544efcf9d3f1078759a5efb13453eee105de 100644 (file)
@@ -6670,7 +6670,10 @@ void GPS_D1011b_Get(GPS_PLap* Lap, UC* p)
     return;
   case pD1011:
   case pD1015:
-    (*Lap)->avg_cadence = *p++;
+    if (*p != 0xff) {
+      (*Lap)->avg_cadence = *p;
+    }
+    *p++;
     (*Lap)->trigger_method = *p++;
     break;
   default:
@@ -7183,7 +7186,10 @@ void GPS_D1007_Get(GPS_PCourse_Lap* clp, UC* p)
   (*clp)->avg_heart_rate = *p++;
   (*clp)->max_heart_rate = *p++;
   (*clp)->intensity = *p++;
-  (*clp)->avg_cadence = *p++;
+  if (*p != 0xff) {
+    (*clp)->avg_cadence = *p;
+  }
+  *p++;
 
   return;
 }
@@ -7232,7 +7238,7 @@ void GPS_D1007_Send(UC* data, GPS_PCourse_Lap clp, int32* len)
 
   *p++ = clp->intensity;
 
-  *p++ = clp->avg_cadence;
+  *p++ = clp->avg_cadence > 0 ? clp->avg_cadence : 0xff;
 
   *len = p-data;